﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace Light.Utility.HtmlTable
{
    public enum Alignment
    {
        Center = 2,
        Default = 4,
        Left = 1,
        Right = 3
    }






    public class Cell
    {
        
        private Alignment _align;
        private Color _backColor;
        private FontSetter _fontSetter;
        private bool _isLink;
        private Row _row;
        private string _text;
        private string _url;

        
        public Cell()
        {
            this._align = Alignment.Default;
            this._fontSetter = FontSetter.Default;
            this._backColor = Color.Empty;
            this._row = null;
            this._text = string.Empty;
            this._isLink = false;
            this._url = string.Empty;
            this._fontSetter = new FontSetter();
            this._isLink = false;
        }

        public Cell(string text)
        {
            this._align = Alignment.Default;
            this._fontSetter = FontSetter.Default;
            this._backColor = Color.Empty;
            this._row = null;
            this._text = string.Empty;
            this._isLink = false;
            this._url = string.Empty;
            this._fontSetter = new FontSetter();
            this._isLink = false;
            this._text = text;
        }

        
        public Alignment Align
        {
            get
            {
                if ((this.Row != null) && (this._align == Alignment.Default))
                {
                    return this.Row.Align;
                }
                return this._align;
            }
            set
            {
                this._align = value;
            }
        }

        public Color BackColor
        {
            get
            {
                if ((this.Row != null) && (this._backColor == Color.Empty))
                {
                    return this.Row.BackColor;
                }
                return this._backColor;
            }
            set
            {
                this._backColor = value;
            }
        }

        public FontSetter FontSetter
        {
            get
            {
                if ((this.Row != null) && this._fontSetter.Equals(FontSetter.Default))
                {
                    this._fontSetter.CopyFrom(this.Row.FontSetter);
                }
                return this._fontSetter;
            }
            set
            {
                this._fontSetter = value;
            }
        }

        public bool IsLink
        {
            get
            {
                return this._isLink;
            }
            set
            {
                this._isLink = value;
            }
        }

        public Row Row
        {
            get
            {
                return this._row;
            }
            set
            {
                this._row = value;
            }
        }

        public string Text
        {
            get
            {
                return this._text;
            }
            set
            {
                this._text = value;
            }
        }

        public string Url
        {
            get
            {
                return this._url;
            }
            set
            {
                this._url = value;
            }
        }
    }



}
